<?php
class orders extends MY_Model{
    public function __construct() {
        parent::__construct();
    }
    
    //insert oder
    //insert product
    public function addOder($fields=array())
    {   
        if(empty($fields)){
            return false;
        }
        $this->db->insert('orders',$fields);
        return $this->db->insert_id();
    }
    
    //get orders
    public function getOrder($order_id=false,$user_id=false){
        if($order_id){
            $this->db->where('order_id',$order_id);
        }
        if($user_id)
            $this->db->where('user_id',$user_id);
        $query = $this->db->get('orders');
        if($order_id){
            return $query->row();
        }
        return $query->result();
    }
    //update order
    public function updateOrder($field=array(),$order_id=false)
    {
        if($order_id){
            $this->db->where('order_id',$order_id);
            $this->db->update('orders',$field);
            return $this->db->affected_rows();
        }
        return false;
    }
    
    //delete order
    public function deleteProduct($order_id=false){
        if($order_id){
            $this->db->where('order+id',$order_id);
            $this->db->delete('orders');
            return true;
        }
        return false;    
    }
}
?>